package com.xwzn.resident.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xwzn.resident.GlideRoundTransform;
import com.xwzn.resident.R;
import com.xwzn.resident.model.HomeShfwXq;

import java.util.List;

/**
 * @Description 生活服务详情适配器
 * @Author HanKaiYang
 * @CreateDate 2019/12/23 11:05
 * @Version 1.0
 */
public class HomeShfwXqAdapter extends BaseQuickAdapter<HomeShfwXq, BaseViewHolder> {
    private Context context;

    public HomeShfwXqAdapter(Context context,List<HomeShfwXq> data) {
        super(R.layout.shfw_recycler_xq,data);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, HomeShfwXq item) {
        ImageView iv = (ImageView) helper.getView(R.id.iv_shfw_rlv_xq);
        RequestOptions options = new RequestOptions()
                .centerCrop()
                .placeholder(R.mipmap.ic_launcher_round)
                .error(R.drawable.ic_launcher_foreground)
                .priority(Priority.HIGH)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .transform(new GlideRoundTransform(5));
        Glide.with(context).load(item.getImage())
                .apply(options)
                .into(iv);
        helper.setText(R.id.tv_shfw_rlv_xq_title,item.getTitle())
                .setText(R.id.tv_shfw_rlv_xq_date,item.getDate())
                .setText(R.id.tv_shfw_rlv_xq_content,item.getContent());
    }
}
